package com.shiyang.seckill.service;

import com.shiyang.seckill.dao.GoodsDao;
import com.shiyang.seckill.domain.SeckillGoods;
import com.shiyang.seckill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shiyang date: 2020/7/20
 */
@Service
public class GoodsService {

    @Autowired
    private GoodsDao goodsDao;

    public List<GoodsVo> listGoodsVo() {
        return goodsDao.listGoodsVo();
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        return goodsDao.getGoodsVoByGoodsId(goodsId);
    }

    public void reduceStock(GoodsVo vo) {
        SeckillGoods goods = new SeckillGoods();
        goods.setId(vo.getId());
        // ? 直接传vo 或者 vo.getId() 测试一下
        goodsDao.reduceStock(goods);
    }
}
